<template>
  <div class="personInfo">
    <div class="info">
      <div>
        <p>
          <label>姓名：</label>
          <span>{{ user.uRealName ?? "--" }}</span>
        </p>
        <p>
          <label>帐号：</label>
          <span>{{ user.uLoginName ?? "--" }}</span>
        </p>
        <!-- <p>
          <label>角色：</label>
          <span>管理员</span>
        </p> -->
        <p>
          <label>性别：</label>
          <span>{{
            user.sex == "1" ? "男" : user.sex == "0" ? "女" : "未知"
          }}</span>
        </p>
        <!-- <p>
          <label>手机号：</label>
          <span>18681232313</span>
        </p> -->
      </div>
    </div>
  </div>
</template>

<script>
import { AjaxCommon } from "@/libs/apiCommon";
import { PopupCommon } from "@/libs/popupCommon";
export default {
  components: {},
  data() {
    return {
      user: {},
    };
  },
  computed: {},
  mounted() {
    // 获取token
    var token = localStorage.getItem("token");
    if (token) {
      token = token.replace("Bearer ", "");
      this.getUser(token);
    }
  },
  methods: {
    getUser(token) {
      let self = this;
      self.user = {};
      AjaxCommon("/api/User/GetInfoByToken?token=" + token, "get", null).then(
        (res) => {
          if (res.data.status == 200) {
            self.user = res.data.response;
          } else {
            PopupCommon.notify("error", res.data.msg);
          }
        }
      );
    },
  },
};
</script>

<style>
.personInfo {
  margin: 10px;
  background-color: #fff;
  height: calc(100vh - 100px);
  text-align: center;
  position: relative;
}
.info {
  width: 500px;
  background-color: #f5f5f5;
  border-radius: 20px;
  height: 300px;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
}
.info div {
  font-size: 16px;
  margin-top: 50px;
}
.info p {
  height: 40px;
  line-height: 40px;
  text-align: center;
}

.info p label {
  width: 48%;
  float: left;
  text-align: right;
  padding-right: 10px;
}
.info p span {
  width: 48%;
  float: left;
  text-align: left;
  padding-left: 10px;
}
</style>
